const onSymptom = (symptom: any) => {
  fields.value.forEach((f) => {
    if (f.fieldId !== focusedField.value) return;

    const editableDiv = document.getElementById(`field1${f.fieldId}`);
    if (!editableDiv) return;

    // 获取当前光标位置
    const selection = window.getSelection();
    if (!selection || selection.rangeCount === 0) return;
    
    const range = selection.getRangeAt(0);
    const startOffset = range.startOffset;
    const endOffset = range.endOffset;
    const textNode = range.startContainer;
    
    // 获取当前内容
    const currentContent = editableDiv.innerText || '';
    
    // 构建要插入的症状文本
    let symptomText = '';
    symptom.forEach((item: { type: any; text: any }, index: number) => {
      if (index > 0) symptomText += '，';
      symptomText += `${item.text}`;
    });
    
    // 在光标位置插入文本
    const newContent = 
      currentContent.substring(0, startOffset) + 
      symptomText + 
      currentContent.substring(endOffset);
    
    // 更新字段内容
    f.content = newContent;
    f.fieldValue = newContent;
    
    // 更新DOM内容
    editableDiv.innerText = newContent;
    
    // 重新设置光标位置到插入文本之后
    const newRange = document.createRange();
    newRange.setStart(textNode, startOffset + symptomText.length);
    newRange.setEnd(textNode, startOffset + symptomText.length);
    selection.removeAllRanges();
    selection.addRange(newRange);
  });

  triggerRef(fields); // 触发视图更新
};